package com.gpframework.module.module.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.module.domain.GpQualityFlowDetails;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpQualityFlowDetailsReq
 * @Author gpframework
 * @Date 2023-12-11
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpQualityFlowDetailsReq extends BaseReq {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("查询日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;
         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("发货日期")
     private Date sendOutGoodsTime;
     @ApiModelProperty("胚布基础表id")
     private Long supplierGreyClothId;
     @ApiModelProperty("供应商名称")
     private String supplierName;
     @ApiModelProperty("批号")
     private String batchNo;
     @ApiModelProperty("产品基础表id")
     private Long produceProductId;
     @ApiModelProperty("产品名")
     private String productName;
     @ApiModelProperty("颜色")
     private String colour;
     @ApiModelProperty("缸号")
     private String dyeVatNo;
     @ApiModelProperty("数量（条数）")
     private Integer quantity;
     @ApiModelProperty("数量（空码）")
     private Integer emptyQuantity;
     @ApiModelProperty("问题表述")
     private String problemDescription;
     @ApiModelProperty("处理方案")
     private String processingScheme;
     @ApiModelProperty("处理进度")
     private String processingProgress;
     @ApiModelProperty("跟进情况1")
     private String followUpSituationOne;
     @ApiModelProperty("跟进情况2")
     private String followUpSituationTwo;
     @ApiModelProperty("完成情况")
     private String completionSituation;
     @ApiModelProperty("完成日期")
     private Date completionTime;
     @ApiModelProperty("退货日期")
     private Date returnOfGoodsTime;
     @ApiModelProperty("退货方式")
     private String returnOfGoodsType;
     @ApiModelProperty("条数")
     private Integer stripQuantity;
     @ApiModelProperty("空码数/公斤数")
     private Integer emptyOrKilogramQuantity;
     @ApiModelProperty("包数")
     private Integer packageQuantity;
     @ApiModelProperty("物流单号")
     private String logisticsTrackingNo;
     @ApiModelProperty("到货日期")
     private Date arrivalTime;
     @ApiModelProperty("收货人id")
     private Long receiveId;
     @ApiModelProperty("收货人名称")
     private String receiveName;
     @ApiModelProperty("收货时间")
     private Date receiveTime;
     @ApiModelProperty("跟单人id")
     private Long followUpId;
     @ApiModelProperty("跟单人名称")
     private String followUpName;
     @ApiModelProperty("跟单时间")
     private Date followUpTime;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
     @ApiModelProperty("更新者")
     private String updateBy;
     @ApiModelProperty("更新时间")
     private Date updateTime;
     @ApiModelProperty("删除标记;0未删除。1已删除。")
     private Integer delStatus;
    /** 操作人名称 */
    @ApiModelProperty("操作人名称")
    private String operatorName;
    /** 操作人编号 */
    @ApiModelProperty("操作人编号")
    private String operatorNum;
    /**审批人名称 */
    @ApiModelProperty("审批人名称")
    private String examinName;
    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpQualityFlowDetails> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
            lqw.orderByDesc(alias+"create_time");
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.like(alias+"sn" ,this.getSn());
        }
        if (this.getSendOutGoodsTime() != null){
        lqw.eq(alias+"send_out_goods_time" ,this.getSendOutGoodsTime());
        }
        if (this.getSupplierGreyClothId() != null){
        lqw.eq(alias+"supplier_grey_cloth_id" ,this.getSupplierGreyClothId());
        }
        if (StringUtils.isNotBlank(this.getSupplierName())){
            lqw.like(alias+"supplier_name",this.getSupplierName());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.eq(alias+"batch_no" ,this.getBatchNo());
        }
        if (this.getProduceProductId() != null){
        lqw.eq(alias+"produce_product_id" ,this.getProduceProductId());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getColour())){
        lqw.like(alias+"colour" ,this.getColour());
        }
        if (StringUtils.isNotBlank(this.getDyeVatNo())){
        lqw.eq(alias+"dye_vat_no" ,this.getDyeVatNo());
        }
        if (this.getQuantity() != null){
        lqw.eq(alias+"quantity" ,this.getQuantity());
        }
        if (this.getEmptyQuantity() != null){
        lqw.eq(alias+"empty_quantity" ,this.getEmptyQuantity());
        }
        if (StringUtils.isNotBlank(this.getProblemDescription())){
        lqw.eq(alias+"problem_description" ,this.getProblemDescription());
        }
        if (StringUtils.isNotBlank(this.getProcessingScheme())){
        lqw.eq(alias+"processing_scheme" ,this.getProcessingScheme());
        }
        if (StringUtils.isNotBlank(this.getProcessingProgress())){
        lqw.eq(alias+"processing_progress" ,this.getProcessingProgress());
        }
        if (StringUtils.isNotBlank(this.getFollowUpSituationOne())){
        lqw.eq(alias+"follow_up_situation_one" ,this.getFollowUpSituationOne());
        }
        if (StringUtils.isNotBlank(this.getFollowUpSituationTwo())){
        lqw.eq(alias+"follow_up_situation_two" ,this.getFollowUpSituationTwo());
        }
        if (StringUtils.isNotBlank(this.getCompletionSituation())){
        lqw.eq(alias+"completion_situation" ,this.getCompletionSituation());
        }
        if (this.getCompletionTime() != null){
        lqw.eq(alias+"completion_time" ,this.getCompletionTime());
        }
        if (this.getReturnOfGoodsTime() != null){
        lqw.eq(alias+"return_of_goods_time" ,this.getReturnOfGoodsTime());
        }
        if (StringUtils.isNotBlank(this.getReturnOfGoodsType())){
        lqw.eq(alias+"return_of_goods_type" ,this.getReturnOfGoodsType());
        }
        if (this.getStripQuantity() != null){
        lqw.eq(alias+"strip_quantity" ,this.getStripQuantity());
        }
        if (this.getEmptyOrKilogramQuantity() != null){
        lqw.eq(alias+"empty_or_kilogram_quantity" ,this.getEmptyOrKilogramQuantity());
        }
        if (this.getPackageQuantity() != null){
        lqw.eq(alias+"package_quantity" ,this.getPackageQuantity());
        }
        if (StringUtils.isNotBlank(this.getLogisticsTrackingNo())){
        lqw.like(alias+"logistics_tracking_no" ,this.getLogisticsTrackingNo());
        }
        if (this.getArrivalTime() != null){
        lqw.eq(alias+"arrival_time" ,this.getArrivalTime());
        }
        if (this.getReceiveId() != null){
        lqw.eq(alias+"receive_id" ,this.getReceiveId());
        }
        if (StringUtils.isNotBlank(this.getReceiveName())){
            lqw.like(alias+"receive_name",this.getReceiveName());
        }
        if (this.getReceiveTime() != null){
        lqw.eq(alias+"receive_time" ,this.getReceiveTime());
        }
        if (this.getFollowUpId() != null){
        lqw.eq(alias+"follow_up_id" ,this.getFollowUpId());
        }
        if (StringUtils.isNotBlank(this.getFollowUpName())){
            lqw.like(alias+"follow_up_name",this.getFollowUpName());
        }
        if (this.getFollowUpTime() != null){
        lqw.eq(alias+"follow_up_time" ,this.getFollowUpTime());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())){
        lqw.eq(alias+"update_by" ,this.getUpdateBy());
        }
        if (this.getUpdateTime() != null){
        lqw.eq(alias+"update_time" ,this.getUpdateTime());
        }
        if (this.getDelStatus() != null){
        lqw.eq(alias+"del_status" ,this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.colour", this.getSearchName()));
        }
        if (this.getSearchDate() != null){
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
